package com.hq.web.util;

import javax.servlet.http.HttpSession;

import org.apache.commons.fileupload.ProgressListener;

public class FileUploadProgressListener implements ProgressListener {
	private HttpSession session;
	public void setSession(HttpSession session){
		this.session=session;
		FileUploadProcessEntity status = new FileUploadProcessEntity();//保存上传状态
		session.setAttribute("upload_ps", status);
	}


	@Override
	public void update(long pBytesRead, long pContentLength, int pItems) {
		FileUploadProcessEntity status = (FileUploadProcessEntity) session.getAttribute("upload_ps");
		try {
			Thread.sleep(5);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		status.setFileItemAry(pBytesRead);
		status.setFileItemArys(pContentLength);
		status.setFileItem(pItems);
		//System.out.println(">>>>>>>>>>>>>>>>>>>>"+status);
		
	}

}
